// pages/tianxie_jyzxx/tianxie_jyzxx.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    xinshu:[
      {id:'',name:"请输入公司名称",credit_no:"请输入税号",start_date:"请输入姓名"},
    ],
    cha_s:'6',
    xs_2:"display:block",
    xian:"display:block",
    xs_3:"display:none",
    xs_4:"display:none",
    xs:"display:none",
    yy_dxs:"display:none",
    tempFilePaths1:"../../images/sf_img1.jpg",
    tempFilePaths2:"../../images/sf_img2.jpg",
    tempFilePaths3:"../../images/sf_img8.jpg",
    tempFilePaths33:"../../images/sf_img8.jpg",
    tempFilePaths31:"../../images/sf_img8.jpg",
    one:0,
    one1:0,
     inputShowed:false,
      inputShowed1:false,
      inputShowed2:false,
      inputShowed3:false,
      inputShowed4:false,
      inputShowed5:false,
      array: ['企业', '事业单位'],
      index: 0,
      array1: ['多证', '多证合一'],
      index1: 0,
  },
  radioChange: function(e) {
    var that = this;
    var xin_s = [];
    var shq_id = e.currentTarget.dataset.id;
    console.log(app.globalData.cha_x)
    for(var i=0;i<app.globalData.cha_x.length;i++){
      console.log(app.globalData.cha_x[i]['reg_no'])
      if(app.globalData.cha_x[i]['reg_no']==shq_id){
        xin_s.push({
          start_date:app.globalData.cha_x[i]['start_date'],
          reg_no:app.globalData.cha_x[i]['reg_no'],
          credit_no:app.globalData.cha_x[i]['credit_no'],
          name:app.globalData.cha_x[i]['name'],
          oper_name:app.globalData.cha_x[i]['oper_name'],
          id:app.globalData.cha_x[i]['id'],
         })
         console.log(xin_s)
         app.globalData.gs_name = app.globalData.cha_x[i]['name']
         app.globalData.sx_dm = app.globalData.cha_x[i]['credit_no']
         that.setData({
          sx_p:"display:none",
          xinshu:xin_s
         })
      }
    }
  },
  xz_x2:function(e){
    var that = this;
    that.data.one1++;
    if(app.globalData.gs_name==''||app.globalData.gs_name==null||app.globalData.gs_name==undefined){
      var  xinshu=[
        {id:'',name:"请输入公司名称",credit_no:"",start_date:"请输入姓名"},
      ];
    }else{
      var  xinshu=[
        {id:'',name:app.globalData.gs_name,credit_no:app.globalData.ruihao,start_date:"请输入姓名"},
      ];
    }
   
    if(that.data.one1==1){
      that.setData({
        xinshu:xinshu
      })
    }
 },
  shanchu:function(e){
    var that = this;
   that.data.xinshu = [
      {id:'',name:"",credit_no:"请输入税号",start_date:"请输入姓名"},
    ],
    app.globalData.ruihao = ''
    app.globalData.gs_name = ''
    that.setData({
      xinshu:that.data.xinshu,
      sx_p:"display:none"
    })
  },
  gs_name:function(e){
    var that = this;
    var gs_name = e.detail.value;
    app.globalData.gs_name = gs_name
    app.globalData.gs_m = gs_name
    // str.replace(""","");
    console.log(app.globalData.gs_name)
          wx.request({
        url: app.globalData.url_l+'api/member/address_check',
        data:{
          address:gs_name
        },
        method: 'post',
        header: {
          'content-type': 'application/x-www-form-urlencoded'
        },
        success: function (res) {
          console.log(res)
          var length = res.data.data.replace(/[^\x00-\xff]/g,"NB").length;  
         　　if(length>=that.data.cha_s){
           console.log(res.data.data)
                wx.showLoading({
                  title: '加载中...',
                  mask: true,
                })
                  wx.request({
                    url: 'https://japi.juhe.cn/enterprise/simpleList?key=a05c8a5da1744fea19877add28f46cd9',
                    data:{
                      keyword:res.data.data
                    },
                    method: 'post',
                    header: {
                      'content-type': 'application/x-www-form-urlencoded'
                    },
                    success: function (res) {
                      console.log(res)
                      setTimeout(function () {
                        wx.hideLoading()   //隐藏loading
                      }, 500)
                      if(res.data.result==''||res.data.result==null||res.data.result==undefined){

                      }else{

                        app.globalData.cha_x = res.data.result.data.items
                         that.setData({
                            sx_p:"display:block",
                            cha_x:res.data.result.data.items
                          })
                      }
                     
                    },
                  })
   }
        },
      })
   

  },

  fr_db:function(e){
    app.globalData.fr_db = e.detail.value
  },
  sx_dm:function(e){
    app.globalData.sx_dm = e.detail.value
    console.log(app.globalData.sx_dm)
  },
  fr_dh:function(e){
    app.globalData.fr_dh = e.detail.value
  },
  bindPickerChange1: function(e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    app.globalData.zj_lei = e.detail.value;
    if(e.detail.value==0){
      this.setData({
        xian:"display:block"
      })
    }else{
      this.setData({
        xian:"display:none"
      })
    }
    this.setData({
      index1: e.detail.value
    })
  },
  zuzhi:function(e){
    app.globalData.zuzhi = e.detail.value
  },
  bindPickerChange: function(e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    app.globalData.zz_lei = e.detail.value
    this.setData({
      index: e.detail.value
    })
  },
  qks1:function(e){
    var that = this;
    that.data.one++;
    if(that.data.one==1){
      that.setData({
        sf_name:""
      })
    }
   
  },
  qks2:function(e){
    var that = this;
    that.data.one1++;
    if(that.data.one1==1){
      that.setData({
        sf_hm:""
      })
    }
   
  },
  tjiao:function(e){

    var that = this;
    if(app.globalData.gs_m==null||app.globalData.gs_m==''||app.globalData.gs_m==undefined){
      wx.showModal({
        title: '',
        content: '请上公司名称',
        showCancel: false,
        success:function(res){
              if(res.confirm){
               
              }else{
                 
              }
        }
      })
    }else if(app.globalData.sx_dm==null||app.globalData.sx_dm==''||app.globalData.sx_dm==undefined){
      console.log(app.globalData.sx_dm)
      wx.showModal({
        title: '',
        content: '请输入社会信用代码',
        showCancel: false,
        success:function(res){
              if(res.confirm){
               
              }else{
                 
              }
        }
      })
    }else if(app.globalData.fr_db==null||app.globalData.fr_db==''||app.globalData.fr_db==undefined){
      wx.showModal({
        title: '',
        content: '请输入法定代表',
        showCancel: false,
        success:function(res){
              if(res.confirm){
               
              }else{
                 
              }
        }
      })
    }else if(app.globalData.kp_lx==null||app.globalData.kp_lx==''||app.globalData.kp_lx==undefined){
      wx.showModal({
        title: '',
        content: '请输入法人电话号码',
        showCancel: false,
        success:function(res){
              if(res.confirm){
               
              }else{
                 
              }
        }
      })
    }else  if(app.globalData.file555==null||app.globalData.file555==''||app.globalData.file555==undefined){
      wx.showModal({
        title: '',
        content: '请上传营业执照',
        showCancel: false,
        success:function(res){
              if(res.confirm){
               
              }else{
                 
              }
        }
      })
    }else if(that.data.index1==0&&(app.globalData.file51==null||app.globalData.file51==''||app.globalData.file51==undefined)){
      wx.showModal({
        title: '',
        content: '请上传税务登记扫描件',
        showCancel: false,
        success:function(res){
              if(res.confirm){
               
              }else{
                 
              }
        }
      })
    }else if(that.data.index1==0&&(app.globalData.file55==null||app.globalData.file55==''||app.globalData.file55==undefined)){
      wx.showModal({
        title: '',
        content: '请上传组织结构照',
        showCancel: false,
        success:function(res){
              if(res.confirm){
               
              }else{
                 
              }
        }
      })
    } else if(that.data.index1==0&&(app.globalData.zuzhi==null||app.globalData.zuzhi==''||app.globalData.zuzhi==undefined)){
      wx.showModal({
        title: '',
        content: '请输入组织结构代码',
        showCancel: false,
        success:function(res){
              if(res.confirm){
               
              }else{
                 
              }
        }
      })
    }else if(app.globalData.zj_lei==1){
     if(app.globalData.file3==null||app.globalData.file3==''||app.globalData.file3==undefined){
        wx.showModal({
          title: '',
          content: '请上传身份证人像照',
          showCancel: false,
          success:function(res){
                if(res.confirm){
                 
                }else{
                   
                }
          }
        })
      }else  if(app.globalData.kp_name==''||app.globalData.kp_name==null||app.globalData.kp_name==undefined){
       console.log(app.globalData.kp_name)
        wx.showModal({
          title: '',
          content: '请确认身份证人像照是否正确',
          showCancel: false,
          success:function(res){
                if(res.confirm){
                 
                }else{
                   
                }
          }
        })
      }else if(app.globalData.sf_z==''||app.globalData.sf_z==null||app.globalData.sf_z==undefined){
        console.log(app.globalData.idcard)
        wx.showModal({
          title: '',
          content: '请确认身份证人像照是否正确',
          showCancel: false,
          success:function(res){
                if(res.confirm){
                 
                }else{
                   
                }
          }
        })
      }else  if(app.globalData.file4==null||app.globalData.file4==''||app.globalData.file4==undefined){
        wx.showModal({
          title: '',
          content: '请上传身份证国徽照',
          showCancel: false,
          success:function(res){
                if(res.confirm){
                 
                }else{
                   
                }
          }
        })
      }else  if(app.globalData.begin==''||app.globalData.begin==null||app.globalData.begin==undefined){
        wx.showModal({
          title: '',
          content: '请确认身份证国徽照是否正确',
          showCancel: false,
          success:function(res){
                if(res.confirm){
                 
                }else{
                   
                }
          }
        })
      }else if(app.globalData.end==''||app.globalData.end==null||app.globalData.end==undefined){
        wx.showModal({
          title: '',
          content: '请确认身份证国徽照是否正确',
          showCancel: false,
          success:function(res){
                if(res.confirm){
                 
                }else{
                   
                }
          }
        })
      }else if (app.globalData.kp_yx.search("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$") == -1){
        wx.showModal({
          title: '',
          content: '邮箱格式错误!',
          showCancel: false,
          success:function(res){
                if(res.confirm){
                 
                }else{
                   
                }
          }
        })
        return false;  
      }else if(app.globalData.byz==2){
        wx.showModal({
          title: '',
          content: '身份证四要素不一致',
          showCancel: false,
          success:function(res){
                if(res.confirm){
                 
                }else{
                   
                }
          }
        })
      }
      // else  if(app.globalData.yizhi!=1||app.globalData.yizhi==''||app.globalData.yizhi==null||app.globalData.yizhi==undefined){
      //   wx.showModal({
      //     title: '',
      //     content: '身份证与手机号不一致',
      //     showCancel: false,
      //     success:function(res){
      //           if(res.confirm){
                 
      //           }else{
                   
      //           }
      //     }
      //   })
      // }
      else{
        wx.request({
          url: app.globalData.url_l + 'api/member/xin_qiye_save',
          method: 'post',
          data:{
            uid:app.globalData.uid,
            corpid:app.globalData.corpid==null?'':app.globalData.corpid,
            company_name:app.globalData.gs_name,
            organizationtype:app.globalData.zz_lei,
            type:app.globalData.zj_lei,
            organizationregno:app.globalData.sx_dm,
            organizationcode:'',
            legal_mobile:app.globalData.kp_lx,
            card_z_img:app.globalData.file3,
            card_f_img:app.globalData.file4,
            emailormobile:app.globalData.kp_yx,
            yingyezhizhao:app.globalData.file555,
            taxCertificateImg:'',
            zuzhi_img:'',
            userid:app.globalData.uid,
          },
          header: {
            'content-type': 'application/x-www-form-urlencoded'
          },
          success: function (res) {
            console.log(res)
            if(res.data.code>0){
              wx.showModal({
                title: '',
                content: '添加成功！',
                showCancel: false,
                success:function(res){
                      if(res.confirm){
                        wx.navigateBack()
                      }else{
                         
                      }
                }
              })
            }else{
              wx.showModal({
                title: '',
                content: res.data.des,
                showCancel: false,
                success:function(res){
                      if(res.confirm){
                        
                      }else{
                         
                      }
                }
              })
            }
          }
        })
      }
    } else if(app.globalData.file3==null||app.globalData.file3==''||app.globalData.file3==undefined){
      wx.showModal({
        title: '',
        content: '请上传身份证人像照',
        showCancel: false,
        success:function(res){
              if(res.confirm){
               
              }else{
                 
              }
        }
      })
    }else  if(app.globalData.kp_name==''||app.globalData.kp_name==null||app.globalData.kp_name==undefined){
     console.log(app.globalData.kp_name)
      wx.showModal({
        title: '',
        content: '请确认身份证人像照是否正确',
        showCancel: false,
        success:function(res){
              if(res.confirm){
               
              }else{
                 
              }
        }
      })
    }else if(app.globalData.sf_z==''||app.globalData.sf_z==null||app.globalData.sf_z==undefined){
      console.log(app.globalData.idcard)
      wx.showModal({
        title: '',
        content: '请确认身份证人像照是否正确',
        showCancel: false,
        success:function(res){
              if(res.confirm){
               
              }else{
                 
              }
        }
      })
    }else  if(app.globalData.file4==null||app.globalData.file4==''||app.globalData.file4==undefined){
      wx.showModal({
        title: '',
        content: '请上传身份证国徽照',
        showCancel: false,
        success:function(res){
              if(res.confirm){
               
              }else{
                 
              }
        }
      })
    }else  if(app.globalData.begin==''||app.globalData.begin==null||app.globalData.begin==undefined){
      wx.showModal({
        title: '',
        content: '请确认身份证国徽照是否正确',
        showCancel: false,
        success:function(res){
              if(res.confirm){
               
              }else{
                 
              }
        }
      })
    }else if(app.globalData.end==''||app.globalData.end==null||app.globalData.end==undefined){
      wx.showModal({
        title: '',
        content: '请确认身份证国徽照是否正确',
        showCancel: false,
        success:function(res){
              if(res.confirm){
               
              }else{
                 
              }
        }
      })
    }else if (app.globalData.kp_yx.search("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$") == -1){
      wx.showModal({
        title: '',
        content: '邮箱格式错误!',
        showCancel: false,
        success:function(res){
              if(res.confirm){
               
              }else{
                 
              }
        }
      })
      return false;  
      }else if(app.globalData.byz==2){
      wx.showModal({
        title: '',
        content: '身份证四要素不一致',
        showCancel: false,
        success:function(res){
              if(res.confirm){
               
              }else{
                 
              }
        }
      })
    }
    // else  if(app.globalData.yizhi!=1||app.globalData.yizhi==''||app.globalData.yizhi==null||app.globalData.yizhi==undefined){
    //   wx.showModal({
    //     title: '',
    //     content: '身份证与手机号不一致',
    //     showCancel: false,
    //     success:function(res){
    //           if(res.confirm){
               
    //           }else{
                 
    //           }
    //     }
    //   })
    // }
    else{
      wx.request({
        url: app.globalData.url_l + 'api/member/xin_qiye_save',
        method: 'post',
        data:{
          uid:app.globalData.uid,
          corpid:app.globalData.corpid==null?'':app.globalData.corpid,
          company_name:app.globalData.gs_name,
          organizationtype:app.globalData.zz_lei,
          type:app.globalData.zj_lei,
          organizationregno:app.globalData.sx_dm,
          organizationcode:app.globalData.zuzhi==undefined?'':app.globalData.zuzhi,
          legal_mobile:app.globalData.kp_lx,
          card_z_img:app.globalData.file3,
          card_f_img:app.globalData.file4,
          emailormobile:app.globalData.kp_yx,
          yingyezhizhao:app.globalData.file555,
          taxCertificateImg:app.globalData.file51==undefined?'':app.globalData.file51,
          zuzhi_img:app.globalData.file55==undefined?'':app.globalData.file55,
          userid:app.globalData.uid,
        },
        header: {
          'content-type': 'application/x-www-form-urlencoded'
        },
        success: function (res) {
          console.log(res)
          if(res.data.code>0){
            wx.showModal({
              title: '',
              content: '添加成功！',
              showCancel: false,
              success:function(res){
                    if(res.confirm){
                      wx.navigateBack()
                    }else{
                       
                    }
              }
            })
          }else{
            wx.showModal({
              title: '',
              content: res.data.des,
              showCancel: false,
              success:function(res){
                    if(res.confirm){

                    }else{
                       
                    }
              }
            })
          }
        }
      })
    }
    
  },
  zc:function(e){
    var that = this;
    that.setData({
      yy_dxs:"display:none",
    })
  },
  ty:function(e){
     wx.navigateTo({
       url: '../qianming/qianming',
     })
  },
  kp_name:function(e){
    app.globalData.kp_name = e.detail.value
  },
  sf_z:function(e){
    app.globalData.sf_z = e.detail.value
  },
  kp_lx:function(e){
    var that = this;
    app.globalData.kp_lx = e.detail.value
    app.globalData.sx_dm = app.globalData.sx_dm
    console.log(app.globalData.sx_dm)
    // var length = app.globalData.kp_lx.replace(/[^\x00-\xff]/g,"NB").length;  
    //      if(length===11){
    //       wx.request({
    //         url: app.globalData.url_l + 'api/member/mobile_check',
    //         method: 'post',
    //         data:{
    //           mobile:app.globalData.kp_lx
    //         },
    //         header: {
    //           'content-type': 'application/x-www-form-urlencoded'
    //         },
    //         success: function (res) {
    //            console.log(res)
    //            app.globalData.state2 = res.data.state
    //           //  if(app.globalData.sf_z==''||app.globalData.sf_z==null||app.globalData.sf_z==undefined){
    //           //   wx.showModal({
    //           //     title: '',
    //           //     content: '身份证号不能为空！',
    //           //     showCancel: false,
    //           //     success:function(res){
    //           //           if(res.confirm){
                         
    //           //           }else{
                           
    //           //           }
    //           //     }
    //           //   })
    //           // }else if(app.globalData.kp_lx==''||app.globalData.kp_lx==null||app.globalData.kp_lx==undefined){
    //           //   wx.showModal({
    //           //     title: '',
    //           //     content: '手机号不能为空！',
    //           //     showCancel: false,
    //           //     success:function(res){
    //           //           if(res.confirm){
                         
    //           //           }else{
                           
    //           //           }
    //           //     }
    //           //   })
    //           // }else{
    //             wx.request({
    //               url: app.globalData.url_l+'api/member/md5_str',
    //               method: 'post',
    //               data:{
    //                 name:app.globalData.kp_name,
    //                 idnum:app.globalData.sf_z,
    //                 mobile:app.globalData.kp_lx
    //               },
    //               header: {
    //                 'content-type': 'application/x-www-form-urlencoded'
    //               },
    //               success: function (res) {
    //                 console.log(res)
    //                 wx.showLoading({
    //                   title: '加载中...',
    //                   mask: true,
    //                 })
    //                  if(app.globalData.state2==1){
    //                   wx.request({
    //                     url: 'https://v.juhe.cn/telecom/query?key=cd105137d4e29b25a451f55f26e5f8dc',
    //                     method: 'post',
    //                     data:{
    //                       realname:app.globalData.kp_name,
    //                       idcard:app.globalData.sf_z,
    //                       mobile:app.globalData.kp_lx
    //                     },
    //                     header: {
    //                       'content-type': 'application/x-www-form-urlencoded'
    //                     },
    //                     success: function (res) {
    //                       console.log(res)
    //                       if(res.data.result==null||res.data.result==''||res.data.result==undefined){
                            
    //                       }else{
    //                         app.globalData.yizhi = res.data.result.res
    //                       }
    //                       setTimeout(function () {
    //                         wx.hideLoading()   //隐藏loading
    //                       }, 500)
    //                     }
    //                   })
    //                 }else if(app.globalData.state2==2){
    //                   console.log(res.data.data.name)
    //                   console.log(res.data.data.idnum)
    //                   console.log(res.data.data.mobile)
    //                   wx.request({
    //                     url: 'https://apis.juhe.cn/telecomctcc_md5/query?key=b49849938c5cb10f01da02851747279a',
    //                     method: 'post',
    //                     data:{
    //                       realname:res.data.data.name,
    //                       idcard:res.data.data.idnum,
    //                       mobile:res.data.data.mobile,
    //                       detail:1
    //                     },
    //                     header: {
    //                       'content-type': 'application/x-www-form-urlencoded'
    //                     },
    //                     success: function (res) {
    //                       console.log(res)
    //                       if(res.data.result==null||res.data.result==''||res.data.result==undefined){
                            
    //                       }else{
    //                         app.globalData.yizhi = res.data.result.res
    //                       }
    //                       setTimeout(function () {
    //                         wx.hideLoading()   //隐藏loading
    //                       }, 500)
    //                     }
    //                   })
    //                   }else if(app.globalData.state2==3){
    //                     wx.request({
    //                       url: 'https://v.juhe.cn/telecom/query?key=cd105137d4e29b25a451f55f26e5f8dc',
    //                       method: 'post',
    //                       data:{
    //                         realname:app.globalData.kp_name,
    //                         idcard:app.globalData.sf_z,
    //                         mobile:app.globalData.kp_lx
    //                       },
    //                       header: {
    //                         'content-type': 'application/x-www-form-urlencoded'
    //                       },
    //                       success: function (res) {
    //                         console.log(res)
    //                         if(res.data.result==null||res.data.result==''||res.data.result==undefined){
                            
    //                         }else{
    //                           app.globalData.yizhi = res.data.result.res
    //                         }
    //                         setTimeout(function () {
    //                           wx.hideLoading()   //隐藏loading
    //                         }, 500)
    //                       }
    //                     })
    //               }else{
    //                 setTimeout(function () {
    //                   wx.hideLoading()   //隐藏loading
    //                 }, 500)
    //                 wx.showModal({
    //                   title: '',
    //                   content: '手机号格式不正确！',
    //                   showCancel: false,
    //                   success:function(res){
    //                         if(res.confirm){
                              
    //                         }else{
                               
    //                         }
    //                   }
    //                 })
                    
    //               }
    //               }
    //             })
                
    //          // }
              
    //         }
    //       })
    //      }
  },
  kp_yx:function(e){
    app.globalData.kp_yx = e.detail.value
  },

  chooseimage1: function (e) {
    var that = this;
    wx.chooseImage({
      count: 1, // 默认9  
      // 可以指定是原图还是压缩图，默认二者都有  
      sizeType: ['original', 'compressed'],
      // 可以指定来源是相册还是相机，默认二者都有
      sourceType: ['album', 'camera'],
      // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片   
      success: function (res) {
        //前台显示
        
         console.log(res)
        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
        var tempFilePaths1 = res.tempFilePaths
        that.setData({
          tempFilePaths1: res.tempFilePaths
        })
        wx.showLoading({
          title: '上传中...',
          mask: true,
        })
        const uploadTask =  wx.uploadFile({
          url: 'https://shy.xihenet.net/api/index/order_img',
          filePath: tempFilePaths1[0],
          name: 'file',
          header: {
            "content-type": "multipart/form-data",
            "content-type": "application/x-www-form-urlencoded"
          },
          success: function (res) {
            //打印
            console.log(res)
            app.globalData.file1 = res.data
            var str = app.globalData.file1;
            app.globalData.file3 = str.replace(/^\"|\"$/g, '');
            console.log(app.globalData.file3)
            console.log(str.replace(/^\"|\"$/g, ''))
            
            wx.getFileSystemManager().readFile({
              filePath: tempFilePaths1[0],
              encoding:"base64",
              success: function (data){
                console.log(data)//返回base64编码结果，但是图片的话没有data:image/png
                wx.showLoading({
                  title: '加载中...',
                  mask: true,
                })
                 wx.request({
                    url: 'https://apis.juhe.cn/idimage/verify?key=0b9429b323f9645b81bb111ff1bb804b',
                    method: 'post',
                    data:{
                      image:data.data,
                      side:1
                    },
                    header: {
                      'content-type': 'application/x-www-form-urlencoded'
                    },
                    success: function (res) {
                      console.log(res)
                      app.globalData.kp_name = res.data.result.realname
                      app.globalData.sf_z = res.data.result.idcard
                      if(app.globalData.kp_name!=''&&app.globalData.kp_name!=null&&app.globalData.kp_name!=undefined&&app.globalData.sf_z!=''&&app.globalData.sf_z!=null&&app.globalData.sf_z!=undefined){
                        console.log(app.globalData.begin)
                        console.log(app.globalData.end)
                        if(app.globalData.begin==""||app.globalData.begin==null||app.globalData.begin==undefined){

                        }else if(app.globalData.end==""||app.globalData.end==null||app.globalData.end==undefined){
                         
                        }else{
                          console.log(1111)
                         wx.request({
                           url: 'https://apis.juhe.cn/id_card_four_factors/query?key=a27670eb14416e7586d180ecc33df39d',
                           method: 'post',
                           data:{
                             realname:app.globalData.kp_name,
                             idcard:app.globalData.sf_z,
                             start_date:app.globalData.begin,
                             end_date:app.globalData.end
                           },
                           header: {
                             'content-type': 'application/x-www-form-urlencoded'
                           },
                           success: function (res) {
                             console.log(res)
                             if(res.data.result.res==1){
                                 app.globalData.byz = 1
                                
                             }else{
                              app.globalData.byz = 2
                             }
                           }
                         })
                        }
                      }
                  
                      if(res.data.result.realname==''||res.data.result.realname==null||res.data.result.realname==undefined){
                        that.setData({
                          xs1_1:"display:none",
                          xs1_2:"display:block",
                         })
                        wx.showModal({
                          title: '',
                          content: '请确认身份证正面是否正确',
                          showCancel: false,
                          success:function(res){
                                if(res.confirm){
                                 
                                }else{
                                   
                                }
                          }
                        })
                      }else if(res.data.result.idcard==''||res.data.result.idcard==null||res.data.result.idcard==undefined){
                       
                        wx.showModal({
                          title: '',
                          content: '请确认身份证正面是否正确',
                          showCancel: false,
                          success:function(res){
                                if(res.confirm){
                                 
                                }else{
                                   
                                }
                          }
                        })
                      }
                        if(res.data.result.realname==''||res.data.result.realname==null||res.data.result.realname==undefined){
                          that.setData({
                            xs1_2:"display:block",
                            xs1_1:"display:none",
                           })
                        }else{
                          that.setData({
                            xs1_1:"display:block",
                            xs1_2:"display:none",
                           })
                        }
                        if(res.data.result.idcard==''||res.data.result.idcard==null||res.data.result.idcard==undefined){
                          that.setData({
                            xs1_4:"display:block",
                            xs1_3:"display:none",
                           })
                       }else{
                        that.setData({
                          xs1_3:"display:block",
                          xs1_4:"display:none",
                         })
                       }
                     
                        that.setData({
                          sf_name:res.data.result.realname,
                          sf_hm:res.data.result.idcard
                       })
                      
                    }
                  })
                  uploadTask.onProgressUpdate((res) => {
                    console.log('上传进度', res.progress)
                    if(res.progress=='100'){
                      setTimeout(function () {
                        wx.hideLoading()   //隐藏loading
                      }, 1000)
                    }
                    console.log('已经上传的数据长度', res.totalBytesSent)
                    console.log('预期需要上传的数据总长度', res.totalBytesExpectedToSend)
                  })
                  setTimeout(function () {
                    wx.hideLoading()   //隐藏loading
                  }, 1000)
              }
            })
          }, fail: function (err) {
          }
        })
      }
    })
  },

  chooseimage2: function (e) {
    var that = this;
    if(app.globalData.file3==null||app.globalData.file3==""||app.globalData.file3==undefined){
      wx.showModal({
        title: '',
        content: '请先上传身份正面图片',
        showCancel: false,
        success:function(res){
              if(res.confirm){
               
              }else{
                 
              }
        }
      })
    }else{
      wx.chooseImage({
        count: 1, // 默认9  
        // 可以指定是原图还是压缩图，默认二者都有  
        sizeType: ['original', 'compressed'],
        // 可以指定来源是相册还是相机，默认二者都有
        sourceType: ['album', 'camera'],
        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片   
        success: function (res) {
          //前台显示
          that.setData({
            tempFilePaths2: res.tempFilePaths
          })
  
          // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
          var tempFilePaths2 = res.tempFilePaths
          wx.showLoading({
            title: '上传中...',
            mask: true,
          })
          const uploadTask =  wx.uploadFile({
            url: 'https://shy.xihenet.net/api/index/order_img',
            filePath: tempFilePaths2[0],
            name: 'file',
            header: {
              "content-type": "multipart/form-data",
              "content-type": "application/x-www-form-urlencoded"
            },
            success: function (res) {
              //打印
              app.globalData.file2 = res.data
              var str = app.globalData.file2;
              str.replace(/^\"|\"$/g, '');
              app.globalData.file4 = str.replace(/^\"|\"$/g, '');
              that.setData({
                tempFilePaths2: "https://shy.xihenet.net/uploads/image/"+app.globalData.file4
              })
              wx.getFileSystemManager().readFile({
                filePath: tempFilePaths2[0],
                encoding:"base64",
                success: function (data){
                  console.log(data)//返回base64编码结果，但是图片的话没有data:image/png
                  wx.showLoading({
                    title: '加载中...',
                    mask: true,
                  })
                   wx.request({
                      url: 'https://apis.juhe.cn/idimage/verify?key=0b9429b323f9645b81bb111ff1bb804b',
                      method: 'post',
                      data:{
                        image:data.data,
                        side: "back"
                      },
                      header: {
                        'content-type': 'application/x-www-form-urlencoded'
                      },
                      success: function (res) {
                        console.log(res)
                        app.globalData.begin = res.data.result.begin
                        app.globalData.end = res.data.result.end
                        if(res.data.result.begin==''||res.data.result.begin==null||res.data.result.begin==undefined){
                          that.setData({
                            xs1_6:"display:block",
                            xs1_5:"display:none",
                           })
                          wx.showModal({
                            title: '',
                            content: '请确认身份证反面是否正确',
                            showCancel: false,
                            success:function(res){
                                  if(res.confirm){
                                   
                                  }else{
                                     
                                  }
                            }
                          })
                        }else if(res.data.result.end==''||res.data.result.end==null||res.data.result.end==undefined){
                          that.setData({
                            xs1_8:"display:block",
                            xs1_7:"display:none",
                           })
                          wx.showModal({
                            title: '',
                            content: '请确认身份证反面是否正确',
                            showCancel: false,
                            success:function(res){
                                  if(res.confirm){
                                   
                                  }else{
                                     
                                  }
                            }
                          })
                        }else{
                          if(res.data.result.begin==''||res.data.result.begin==null||res.data.result.begin==undefined){
                            that.setData({
                              xs1_6:"display:block",
                              xs1_5:"display:none",
                             })
                         }else{
                          that.setData({
                            xs1_5:"display:block",
                            xs1_6:"display:none",
                           })
                         }
                         if(res.data.result.end==''||res.data.result.end==null||res.data.result.end==undefined){
                          that.setData({
                            xs1_8:"display:block",
                            xs1_7:"display:none",
                           })
                        }else{
                          that.setData({
                            xs1_7:"display:block",
                            xs1_8:"display:none",
                           })
                        }

                          if(res.data.reason=="成功"){
                            wx.request({
                              url: 'https://apis.juhe.cn/id_card_four_factors/query?key=a27670eb14416e7586d180ecc33df39d',
                              method: 'post',
                              data:{
                                realname:app.globalData.kp_name,
                                idcard:app.globalData.sf_z,
                                start_date:app.globalData.begin,
                                end_date:app.globalData.end
                              },
                              header: {
                                'content-type': 'application/x-www-form-urlencoded'
                              },
                              success: function (res) {
                                 console.log(res)
                                 if(res.data.result.res==1){
                                     app.globalData.byz = 1
                                    
                                 }else{
                                  app.globalData.byz = 2
                                 }
                              }
                            })
                          //   that.setData({
                          //     sf_name:res.data.result.realname,
                          //     sf_hm:res.data.result.idcard
                          //  })
                          }
                        }
                     
                      }
                    })
                    uploadTask.onProgressUpdate((res) => {
                      console.log('上传进度', res.progress)
                      if(res.progress=='100'){
                        setTimeout(function () {
                          wx.hideLoading()   //隐藏loading
                        }, 1000)
                      }
                      console.log('已经上传的数据长度', res.totalBytesSent)
                      console.log('预期需要上传的数据总长度', res.totalBytesExpectedToSend)
                    })
                    setTimeout(function () {
                      wx.hideLoading()   //隐藏loading
                    }, 1000)
                }
              })
            }, fail: function (err) {
            }
          })
        }
      })
    }
   
  },
  chooseimage3: function (e) {
    var that = this;
    wx.chooseImage({
      count: 1, // 默认9  
      // 可以指定是原图还是压缩图，默认二者都有  
      sizeType: ['original', 'compressed'],
      // 可以指定来源是相册还是相机，默认二者都有
      sourceType: ['album', 'camera'],
      // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片   
      success: function (res) {
        //前台显示
        that.setData({
          tempFilePaths3: res.tempFilePaths
        })

        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
        var tempFilePaths3 = res.tempFilePaths
        wx.showLoading({
          title: '上传中...',
          mask: true,
        })
        const uploadTask = wx.uploadFile({
          url: 'https://shy.xihenet.net/api/index/order_img',
          filePath: tempFilePaths3[0],
          name: 'file',
          header: {
            "content-type": "multipart/form-data",
            "content-type": "application/x-www-form-urlencoded"
          },
          success: function (res) {
            //打印
            app.globalData.file555 = res.data
            var str = app.globalData.file555;
            str.replace(/^\"|\"$/g, '');
            app.globalData.file555 = str.replace(/^\"|\"$/g, '');
            that.setData({
              tempFilePaths3: "https://shy.xihenet.net/uploads/image/"+app.globalData.file555,
              xs:"display:block"
            })
          
          }, fail: function (err) {
          }
        })
        uploadTask.onProgressUpdate((res) => {
          console.log('上传进度', res.progress)
          if(res.progress=='100'){
            setTimeout(function () {
              wx.hideLoading()   //隐藏loading
            }, 1000)
          }
          console.log('已经上传的数据长度', res.totalBytesSent)
          console.log('预期需要上传的数据总长度', res.totalBytesExpectedToSend)
        })
      }
    })
  },
  chooseimage31: function (e) {
    var that = this;
    wx.chooseImage({
      count: 1, // 默认9  
      // 可以指定是原图还是压缩图，默认二者都有  
      sizeType: ['original', 'compressed'],
      // 可以指定来源是相册还是相机，默认二者都有
      sourceType: ['album', 'camera'],
      // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片   
      success: function (res) {
        //前台显示
        that.setData({
          tempFilePaths31: res.tempFilePaths
        })

        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
        var tempFilePaths3 = res.tempFilePaths
        wx.showLoading({
          title: '上传中...',
          mask: true,
        })
        const uploadTask = wx.uploadFile({
          url: 'https://shy.xihenet.net/api/index/order_img',
          filePath: tempFilePaths3[0],
          name: 'file',
          header: {
            "content-type": "multipart/form-data",
            "content-type": "application/x-www-form-urlencoded"
          },
          success: function (res) {
            //打印
            app.globalData.file51 = res.data
            var str = app.globalData.file51;
            str.replace(/^\"|\"$/g, '');
            app.globalData.file51 = str.replace(/^\"|\"$/g, '');
            that.setData({
              tempFilePaths31: "https://shy.xihenet.net/uploads/image/"+app.globalData.file51,
              xs:"display:block"
            })
          
          }, fail: function (err) {
          }
        })
        uploadTask.onProgressUpdate((res) => {
          console.log('上传进度', res.progress)
          if(res.progress=='100'){
            setTimeout(function () {
              wx.hideLoading()   //隐藏loading
            }, 1000)
          }
          console.log('已经上传的数据长度', res.totalBytesSent)
          console.log('预期需要上传的数据总长度', res.totalBytesExpectedToSend)
        })
      }
    })
  },
  chooseimage33: function (e) {
    var that = this;
    wx.chooseImage({
      count: 1, // 默认9  
      // 可以指定是原图还是压缩图，默认二者都有  
      sizeType: ['original', 'compressed'],
      // 可以指定来源是相册还是相机，默认二者都有
      sourceType: ['album', 'camera'],
      // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片   
      success: function (res) {
        //前台显示
        that.setData({
          tempFilePaths33: res.tempFilePaths
        })

        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
        var tempFilePaths33 = res.tempFilePaths
        wx.showLoading({
          title: '上传中...',
          mask: true,
        })
        const uploadTask = wx.uploadFile({
          url: 'https://shy.xihenet.net/api/index/order_img',
          filePath: tempFilePaths33[0],
          name: 'file',
          header: {
            "content-type": "multipart/form-data",
            "content-type": "application/x-www-form-urlencoded"
          },
          success: function (res) {
            //打印
            app.globalData.file55 = res.data
            var str = app.globalData.file55;
            str.replace(/^\"|\"$/g, '');
            app.globalData.file55 = str.replace(/^\"|\"$/g, '');
            that.setData({
              tempFilePaths33: "https://shy.xihenet.net/uploads/image/"+app.globalData.file55,
              xs:"display:block"
            })
            
          }, fail: function (err) {
          }
        })
        uploadTask.onProgressUpdate((res) => {
          console.log('上传进度', res.progress)
          if(res.progress=='100'){
            setTimeout(function () {
              wx.hideLoading()   //隐藏loading
            }, 1000)
          }
          console.log('已经上传的数据长度', res.totalBytesSent)
          console.log('预期需要上传的数据总长度', res.totalBytesExpectedToSend)
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */

  onLoad: function (options) {
    console.log(app.globalData.uid)
    var that = this;
    app.globalData.zj_lei = 0;
    app.globalData.zz_lei = 0;
    app.globalData.file3 = ""
    app.globalData.file4 = ""
    app.globalData.kp_name = ""
    app.globalData.sf_z = ""
    app.globalData.begin = ""
    app.globalData.end = ""
    app.globalData.kp_name = ""
    app.globalData.sf_z = ""
    app.globalData.file5 = ""
    app.globalData.kp_lx = ""
    app.globalData.kp_yx = ""
    app.globalData.byz = ""
    app.globalData.yizhi = ""
    that.setData({
      sf_name:"请输入法定代表",
      sf_hm:"请输入法定代表的身份证号"
   })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})